package com.akk.action;


import com.akk.business.AvsApplyLoanBusiness;
import com.akk.module.avs.model.request.AvsIncreRecordRequest;
import com.akk.utils.RestResponse;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping(value = "/thmlfApi/loan")
@Api(value = "贷款增值API")
public class AvsIncreLoanAction {

    @Autowired
    private AvsApplyLoanBusiness applyLoanBusiness;

    @ApiOperation(value = "获取贷款列表",httpMethod = "GET",response = RestResponse.class)
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query",dataType = "Int",name = "page",value = "当前页,默认为1",required = true),
            @ApiImplicitParam(paramType = "query",dataType = "Int",name = "limit",value = "返回条数,默认为6",required = true)
    })
    @RequestMapping(value = "/list")
    public RestResponse list(@RequestParam(required = false) Integer page, @RequestParam(required = false) Integer limit){
        return applyLoanBusiness.list(page, limit);
    }

    @ApiOperation(value = "获取主页主推信息",httpMethod = "GET",response = RestResponse.class)
    @RequestMapping(value = "/recom")
    public RestResponse recom(){
        return applyLoanBusiness.recom();
    }

    @ApiOperation(value = "获取贷款详细信息",httpMethod = "GET",response = RestResponse.class)
    @RequestMapping(value = "/info/{loanId}")
    public RestResponse info(@PathVariable Long loanId){
        return applyLoanBusiness.info(loanId);
    }

    @ApiOperation(value = "记录用户申请信息",httpMethod = "GET",response = RestResponse.class)
    @RequestMapping(value = "/record",method = RequestMethod.POST)
    public RestResponse saveRecord(@Valid @ApiParam(name = "申请记录",value = "传入JSON对象",required = true) AvsIncreRecordRequest recordRequest, BindingResult bindingResult){
        return applyLoanBusiness.saveRecord(recordRequest, bindingResult);
    }

}
